<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>地址管理</title>

		<link href="/static/home/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="/static/home/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

		<link href="/static/home/css/personal.css" rel="stylesheet" type="text/css">
		<link href="/static/home/css/addstyle.css" rel="stylesheet" type="text/css">
		<script src="/static/home/AmazeUI-2.4.2/assets/js/jquery.min.js" type="text/javascript"></script>
		<script src="/static/home/AmazeUI-2.4.2/assets/js/amazeui.js"></script>

	</head>

	<body>
		<!--头 -->
		<header>
			<article>
				<div class="mt-logo">
					<!--顶部导航条 -->
					<div class="am-container header">
						<ul class="message-r">
							{if condition="!empty($Think.session.uid)" }
						     <div class="topMessage home"> 
						      <div class="menu-hd">
						       <a href="/home/index" class="h">商城首页</a>
						      </div> 
						     </div>

						     <div class="topMessage my-shangcheng"> 
						      <div class="menu-hd MyShangcheng">
						       <a target="_top" href="/orderinfo/grxx"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
						      </div> 
						     </div>
						     
						     <div class="topMessage mini-cart"> 
						      <div class="menu-hd">
						       <a id="mc-menu-hd" href="/cart/index" target="_top" ><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h"></strong></a>
						      </div> 
						     </div>

						     <div class="topMessage favorite"> 
						      <div class="menu-hd">
						       <a href="/orderinfo/collection" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
						      </div> 
						     </div>
						     {/if}
						</ul>
						</div>

						<!--悬浮搜索框-->

						<div class="nav white">
							<div class="logoBig" style="position:relative;top:-15px;right:100px;">
								<li><img src="/static/home/images/aishang.png" /></li>
							</div>

							<div class="search-bar pr">
								<a name="index_none_header_sysc" href="#"></a>
								<form>
									<input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
									<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
								</form>
							</div>
						</div>

						<div class="clear"></div>
					</div>
				</div>
			</article>
		</header>

		<div class="nav-table">
					   <div class="long-title"><span class="all-goods">全部分类</span></div>
					   <div class="nav-cont">
							<ul>
								 <li class="index"><a href="/home/index">首页</a></li>
								  {foreach name="brand" item="bra"}
								      <li class="qc"><a href="/home/brand/id/{$bra['id']}">{$bra['brand']}</a></li>
								  {/foreach}
							</ul>
						    <div class="nav-extra">
						    	<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
						    	<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
						    </div>
						</div>
			</div>
			<b class="line"></b>

		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-address">
						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small></div>
						</div>
						<hr/>
						<ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
							{foreach name="address" item="val"}
							
							<li class="user-addresslist">
								<span class="new-option-r"><i class="am-icon-check-circle"></i></span>
								<p class="new-tit new-p-re">
									<span class="new-txt">{$val['name']}</span>
									<span class="new-txt-rd2">{$val['phone']}</span>
								</p>
								<div class="new-mu_l2a new-p-re">
									<p class="new-mu_l2cw">
										<span class="title">地址：</span>
										
										<span class="street">{$val['huo']}{$val['adds']}</span></p>
								</div>
								<div class="new-addr-btn">
									
									<a href="javascript:void(0);" class="deladdress" name="{$val['id']}"><i class="am-icon-trash"></i>删除</a>
								</div>
							</li>
							{/foreach}
							
							
						</ul>
						<div class="clear"></div>
						<a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
						<!--例子-->
						<div class="am-modal am-modal-no-btn" id="doc-modal-1">

							<div class="add-dress">

								<!--标题 -->
								<div class="am-cf am-padding">
									<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add&nbsp;address</small></div>
								</div>
								<hr/>
				<div class="am-u-md-12 am-u-lg-8">
					<form class="am-form am-form-horizontal" action="/orderinfo/insertaddress" method="post">

						<div class="am-form-group">
							<label for="user-name" class="am-form-label">收货人</label>
							<div class="am-form-content">
								<input type="text" id="user-name" placeholder="收货人"name="name">
							</div>
						</div>

						<div class="am-form-group">
							<label for="user-phone" class="am-form-label">手机号码</label>
							<div class="am-form-content">
								<input id="user-phone" placeholder="手机号必填" type="text" name="phone">
							</div>
						</div>

						<div class="am-form-group">
							<label for="user-phone" class="am-form-label">所在地</label>
							<div class="am-form-content address">
								<select  id="sid">
									<option value="" class="ss">--请选择--</option>
								</select>
								  <input type="hidden" name="huo" value="">
							</div>
						</div>

						<div class="am-form-group">
							<label for="user-intro" class="am-form-label">详细地址</label>
							<div class="am-form-content">
								<textarea class="" rows="3" id="user-intro" placeholder="输入详细地址" name="adds"></textarea>
								<small>100字以内写出你的详细地址...</small>
							</div>
						</div>

						<div class="am-form-group theme-poptit">
							<div class="am-u-sm-9 am-u-sm-push-3">
								<button class="am-btn am-btn-danger">保存</button>
								<div class="am-btn am-btn-danger close">取消</div>
							</div>
						</div>
					</form>



				</div>
							</div>

						</div>

					</div>

					<script type="text/javascript">
						$(document).ready(function() {							
							$(".new-option-r").click(function() {
								$(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
							});
							
							var $ww = $(window).width();
							if($ww>640) {
								$("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
							}
							
						})
					</script>

					<div class="clear"></div>

				</div>
				<!--底部-->
				<div class="footer "> 
				     <div class="footer-hd "> 
				      <p> 
				          <span>友情链接</span> 
				        {foreach name="links" item="links"}
				          <a href="http://{$links['linksaddress']}" target="_blank">{$links['linksname']}</a> <b>|</b>
				        {/foreach} 
				      </p> 
				     </div> 
				     <div class="footer-bd "> 
				      <p> <a href="# ">关于爱上零食屋</a>&nbsp&nbsp&nbsp&nbsp&nbsp 
				      <a href="# ">合作伙伴</a>&nbsp&nbsp&nbsp&nbsp&nbsp  
				      <a href="# ">联系我们</a></p> 
				     </div> 
				    </div> 
			</div>

			<aside class="menu">
				<ul>
					<li class="person">
						<a href="/orderinfo/grxx">个人中心</a>
					</li>
					<li class="person">
						<ul>
							<li> <a href="/orderinfo/grxx">个人信息</a></li>
							<!-- <li> <a href="">安全设置</a></li> -->
							<li class="active"> <a href="/orderinfo/addressa">收货地址</a></li>
						</ul>
					</li>
					<li class="person">
						<a href="#">我的交易</a>
						<ul>
							<li><a href="/orderinfo/index">订单管理</a></li>
						</ul>
					</li>

					<li class="person">
						<a href="#">我的小窝</a>
						<ul>
							<li> <a href="/orderinfo/collection">收藏</a></li>
							<li> <a href="/orderinfo/evaluate/uid/{$Think.session.uid}">评价</a></li>
						</ul>
					</li>

				</ul>

			</aside>
		</div>
	</body>
	<script type="text/javascript">
	// 第一级别获取
	$.get('/orderinfo/two',{upid:0},function(data){
		//console.log(data);
		//将请选择禁止使用
		$('.ss').attr('disabled',true);
		//得到数据数组内容 我们需要遍历得到里面内容
		for(var i = 0;i<data.length;i++){
			//console.log(data[i].name);
			//遍历到option标签中
			var info =$('<option value="'+data[i].id+'">'+data[i].name+'</option>');
			//console.log(info);
			//将得到的option对象添加到select对象中
			$('#sid').append(info);
		}
	},'json');

	//其他级别
	$('body').on('change','select',function(){
		 //alert($(this).val());
		ob = $(this);
		//清除其他 select
		ob.nextAll('select').remove();
		id = ob.val();
		console.log(id);
		$.getJSON('/orderinfo/two',{upid:id},function(data){
			console.log(data);
			var select = $('<select></select>');
			var op = $('<option value="" class="mm">-请选择-</option>');
			select.append(op);
			for(var i=0;i<data.length;i++){
				var info =$('<option value="'+data[i].id+'">'+data[i].name+'</option>');
				// console.log(data[i].name);
				select.append(info);
			}

			ob.after(select);
			//把其他级别的请选择禁用掉
			$('.mm').attr('disabled',true);
		})

	})

	// $('.btnsss').on("click",function(){
	// 	alert(123);
	// })


	//获取选中的数据提交到操作页面
	$('button').click(function(){
		arr=[];
		//console.log($("select"));
		//遍历select
		$('select').each(function(){
			//获取选中的数据
			sedata = $(this).find('option:selected').html();
			//console.log(sedata);

			arr.push(sedata);
			//console.log(arr);

		})
		//删除最有一个数组请选择
	 	arr.pop();
		//console.log(arr);
		//把数据赋值给隐藏域value
		$("input[name='huo']").val(arr);
	})

	$(".deladdress").click(function(){
		ob=$(this);
		id=ob.attr('name');

		//ajax
		$.get("/orderinfo/deladdr",{id:id},function(data){
			if(data==1){
				ob.parents('li').remove();
			}
		})

	})
	

</script>

</html>